<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class CreateStudentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('students', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('mechanism_id')->default(0)->comment('所属机构');
            $table->unsignedInteger('class_id')->default(0)->comment('所属班级');
            $table->string('name')->default('')->comment('学生姓名');
            $table->string('username', 120)->unique()->comment('账号');
            $table->string('password', 80)->default('')->comment('密码');
            $table->string('pwd', '25')->default('')->comment('明密码');
            $table->timestamps();
            $table->timestamp('deleted_at')->nullable();
        });
        DB::statement("ALTER TABLE `students` comment '学生表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('students');
    }
}
